{extend name="public/base"/}
{block name="body"}
<title>经典案例</title>
<style type="text/css">
	.pagelist ul li{display:inline-block;width:20px;height:20px;text-align:center;}
	.pagelist ul li a{width:20px;height:20px;}
	.pagelist ul li.active{background-color:#ccc !important;color:#fff;}
	.type{width:80px;height:30px;border:solid 1px #ddd;}
	.select_type,.select_state{width:80px;height:30px;border:solid 1px #ddd;}
</style>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 后台管理 <span class="c-gray en">&gt;</span> 经典案例 <span class="c-gray en">&gt;</span> 经典案例 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<form class="text-c">
		类型： 
		<select id="select_type" class="select_type" name="type" size="1">
				<option value="0" {if $type==0}selected{/if}>全部</option>
				<option value="1" {if $type==1}selected{/if}>高端定制</option>
				<option value="2" {if $type==2}selected{/if}>微信小程序</option>
				<option value="3" {if $type==3}selected{/if}>APP开发</option>
				<option value="4" {if $type==4}selected{/if}>社区电商</option>
				<option value="5" {if $type==5}selected{/if}>企业微信</option>
				<option value="6" {if $type==6}selected{/if}>新媒体运营</option>
		</select>
		启用状态： 
		<select id="select_state" class="select_state" name="state" size="1">
				<option value="0" {if $state==0}selected{/if}>全部</option>
				<option value="1" {if $state==1}selected{/if}>启用</option>
				<option value="2" {if $state==2}selected{/if}>禁用</option>
		</select> 日期范围：
		
		<input name="fromtime" type="text" {literal} onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" {/literal} id="datemin" class="input-text Wdate" style="width:120px;" value="{$fromtime}">
		-
		<input name="totime" type="text" {literal} onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" {/literal} id="datemax" class="input-text Wdate" style="width:120px;" value="{$totime}">
		
		<input type="text" class="input-text" style="width:250px" placeholder="输入标题" id="keyword" name="keyword" value="{$keyword}">
		<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
	</form>
	<div class="cl pd-5 bg-1 bk-gray mt-20">
		<span class="l">
			<a href="javascript:;" onclick="server_add('添加经典案例','{:url('cases_add')}','800','500')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加经典案例</a>
			<a href="javascript:;" onclick="server_set('合作伙伴主副标题设置','{:url('partner/partners_title')}','800','500')" class="btn btn-primary radius">合作伙伴主副标题设置</a>
		</span>
	</div>
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="9"><span class="r">共有数据：<strong>{$counts}</strong> 条</span></th>
			</tr>
			<tr class="text-c">
				<th width="40">ID</th>
				<th width="40">排序</th>
				<th width="100">ICON</th>
				<th width="100">名称</th>
				<th width="80">描述</th>
				<th width="50">类型</th>
				<th width="50">是否启用</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
			{foreach $list as $key=>$value }
			<tr class="text-c" id="val_{$value.id}">
				<td>{$value.id}</td>
				<td>{$value.sort}</td>
				<td><img style="width:50px;height:30px;background-color:#1c73d3;" src="{$value.icon}"></td>
				<td>{$value.title}</td>
				<td>{$value.description}</td>
				<td class="td-type" id="type_nf{$value.id}">
					{if $value.type==1}
					高端定制
					{elseif $value.type==2}
					微信小程序
					{elseif $value.type==3}
					APP开发
					{elseif $value.type==4}
					社区电商
					{elseif $value.type==5}
					企业微信
					{elseif $value.type==6}
					新媒体运营
					{/if}
				</td>
				<td class="td-status" id="state_nf{$value.id}">
					{if $value.state==1}
						<span class="label label-success radius" style="cursor:pointer;" onClick="state_off({$value.id});">启用</span>
					{elseif $value.state==2}
						<span class="label label-error radius" style="cursor:pointer;" onClick="state_on({$value.id});">禁用</span>
					{/if}
				</td>
				<td class="td-manage">
					<a title="编辑" href="javascript:;" onclick="server_edit('物流路线编辑','{:url('cases_edit')}?id={$value.id}',{$value.id},'800','500')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
					<a title="删除" href="javascript:;" onclick="server_del(this,{$value.id})" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
				</td>
			</tr>
      		{/foreach}
		    <tr>
		        <td colspan="12">
			        <div class="pagelist"  style="text-align: right;">
			        	{$list->render()|raw}
			        </div>
		        </td>
		    </tr>
		</tbody>
	</table>
</div>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="/static/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="/static/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
/*分类-增加*/
function server_add(title,url,w,h){
	layer_show(title,url,w,h);
}
function server_set(title,url,w,h){
	layer_show(title,url,w,h);
}
/*分类-删除*/
function server_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: 'cases_del',
			data:{id:id},
			success: function(data){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:3000});
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
/*分类-编辑*/
function server_edit(title,url,id,w,h){
	layer_show(title,url,w,h);
}

function state_off(id){
	$.post('{:url("state_off")}',
    {id:id},
    function(data){
        if(data.code==200){
            var a='<span class="label label-error radius" style="cursor:pointer;" onClick="state_on('+id+');">禁用</span>'
            $('#state_nf'+id).html(a);
            return false;
        }
    });
    return false;
}
/*管理员-启用*/
function state_on(id){
	$.post('{:url("state_on")}',
    {id:id},
    function(data){
        if(data.code==200){
            var a='<span class="label label-success radius" style="cursor:pointer;" onClick="state_off('+id+');">启用</span>'
            $('#state_nf'+id).html(a);
            return false;
        }
    });
    return false;
}
$(".pagelist").on("click",".pagination a",function(){
  var url=$(this).attr("href");
  var fromtime=$("#datemin").val();
  var totime=$("input[name=totime]").val();
  var keyword=$("#keyword").val();
  var state=$("#select_state").val();
  var type=$("#select_type").val();
  url=url+'&fromtime='+fromtime+'&totime='+totime+'&keyword='+keyword+'&state='+state+'&type='+type;
  getPage(url);
  return false;
});
function getPage(url)
{
  $.get(url, function(data){
    $("body").html(data);

  });
}
</script>
{/block}